<template>
  <div class="order-product" :class="{'product-tiny': isTiny}">
    <div class="img">
      <van-image
        class="img-item"
        fit="cover"
        :src="product.image"
      />
    </div>
    <div class="info">
      <div class="label">
        {{ product.name }}
      </div>
      <div class="desc">
        {{ product.desc }}
      </div>
      <div class="price-section">
        <span v-if="!isTiny" class="price"><small>￥</small>{{ product.price }}</span>
        <span class="count">&times;{{ product.count }}</span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'ProductCell',
  props: {
    product: {
      type: Object,
      default () {
        return {}
      }
    },
    type: {
      type: String,
      default () {
        return ''
      }
    }
  },
  data () {
    return {}
  },
  computed: {
    isTiny () {
      return this.type === 'tiny'
    }
  },
  methods: {
    onClick () {
      this.$emit('click', this.value)
    }
  }
}
</script>

<style lang="less">
  .order-product {
    height: 70px;
    background: #fff;
    display: flex;
    margin: 0 10px;
    align-items: flex-start;
    border-radius: 5px;

    + .order-product {
      margin-top: 10px;
    }

    .img {
      display: flex;
      align-content: center;
    }

    .img-item {
      width: 70px;
      height: 70px;
    }

    .info {
      padding: 0 10px;
      color: #333;
      width: 100%;
    }

    .label {
      font-weight: bold;
      display: flex;
      justify-content: space-between;
    }

    .desc {
      font-size: 12px;
      color: #666;
      line-height: 2;
    }

    .price-section {
      margin-top: 5px;
      display: flex;
      justify-content: space-between;
      align-items: center;
    }

    .price {
      color: red;
      font-size: 16px;
    }

    .inventory {
      font-size: 12px;
      color: #666;
    }

    &.product-tiny {
      .label {
        font-weight: normal;
      }
    }
  }
</style>
